package com.cyurs.netty.nettySimple.EncoderAndDecoder;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/11/26
 */
public class NettyServerInitialize extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new LongToMessageDecoder()); //添加解码器
        pipeline.addLast(new MessageToLongEncoder());
        pipeline.addLast(new NettyServerHandler()); //添加自定义Handler
    }
}
